<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>HTML DOM</title>
	<style type="text/css">
		.f1{
			font-size:30px;
			color:#f00;
		}
	</style>
	<script>
		function applyClass(){
			//1.获取对象
			var pEle = document.getElementById('p');
			//2.设置属性(注意className的写法)
			pEle.className = 'f1';
		}
	</script>
</head>
<body>
	<p id="p">中华人民共和国万岁</p>
	<input type="button" value="单击我,为段落使用f1CSS类" onclick="applyClass()">
</body>
</html>